package com.hero.jobweb.action.common;

import java.util.Calendar;
import java.util.List;

import com.hero.jobweb.action.template.PaginationActionExecuteTemplate;
import com.hero.jobweb.entity.TbOperateLog;
import com.hero.jobweb.service.ICommonService;
import com.hero.web.action.BasePaginationAction;
import com.opensymphony.xwork2.Action;


/**
 * 操作日志Action
 * @author Volcano
 *
 */
public class OperateLogAction extends BasePaginationAction{

	private List<TbOperateLog> operateLogList=null;
	private String remark;
	private Integer Id;
	public Integer getId() {
		return Id;
	}


	public void setId(Integer id) {
		Id = id;
	}


	public String getRemark() {
		return remark;
	}


	public void setRemark(String remark) {
		this.remark = remark;
	}


	private ICommonService commonService= (ICommonService) getBean("commonServiceImpl");
	public List<TbOperateLog> getOperateLogList() {
		return operateLogList;
	}


	public void setOperateLogList(List<TbOperateLog> operateLogList) {
		this.operateLogList = operateLogList;
	}


	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	
	/**
	 * 操作日志列表
	 */
	public String queryOperateLogList()
	{
		TbOperateLog operateLog=new TbOperateLog();
		new PaginationActionExecuteTemplate(this,operateLog) {
			
			public void doImpl() {
				operateLogList=commonService.queryOperateLog((TbOperateLog) getBaseEntity());
			}
		}.execute();
		return Action.SUCCESS;
	}
	
	/**
	 * 保存操作日志
	 * @return
	 */
	public String saveOperateLog()
	{	
		TbOperateLog operateLog=new TbOperateLog();
		operateLog.setTypeCode("00035");
		operateLog.setIP(this.request.getRemoteAddr());
		operateLog.setRemark(getRemark());
		operateLog.setDescription(getRemark());
		operateLog.setCreateTime(Calendar.getInstance().getTime());
		operateLog.setUserId(1);
		commonService.saveOperateLog(operateLog);
//		this.commonService.jtaTest();
		return queryOperateLogList();
	}
	/**
	 * 删除操作日志
	 * @return
	 */
	public String removeOperateLog()
	{
		TbOperateLog operateLog=new TbOperateLog();
		operateLog.setId(getId());
		commonService.removeOperateLog(operateLog);
		return queryOperateLogList();
	}

}
